package com.coder.books.thinkinjava.generics;

/**
 * 15.10.3 无界通配符
 *
 * @author yuhushuan
 * @date 2020/8/11 09:15
 */
public class Wildcards {
    static void rawArgs(Holder holder, Object arg) {
        holder.set(arg);
        holder.set(new Wildcards());

//        T t = holder.get();

        Object obj = holder.get();
    }

    static void unboundedArg(Holder<?> holder, Object arg) {
//        holder.set(arg);
//        holder.set(new Wildcards());

//        T t = holder.get();
        Object obj = holder.get();
    }

    static <T> T exact1(Holder<T> holder) {
        T t = holder.get();
        return t;
    }

    static <T> T exact2(Holder<T> holder, T arg) {
        holder.set(arg);
        T t = holder.get();
        return t;
    }

    static <T> T wildSubtype(Holder<? extends T> holder, T arg) {
//        holder.set(arg);
        T t = holder.get();
        return t;
    }

    static <T> void wildSupertype(Holder<? super T> holder, T arg) {
        holder.set(arg);
//        T t = holder.get();
        Object obj = holder.get();
    }


}
